
# Replication Files for "The Grass is Always Greener on the Other Side: Transnational Ethnic Inequality and Ethno-nationalist Conflict"  

**Authors:** Chong Chen, Kyle Beardsley, and Nils B. Weidmann  
**Journal:** *Journal of Peace Research*  

## Citation  
Please use the following citation when referencing this work:  
Chong Chen, Kyle Beardsley, and Nils B. Weidmann. “The Grass is Always Greener on the Other Side: Transnational Ethnic Inequality and Ethno-nationalist Conflict.” *Journal of Peace Research.*, https://doi.org/10.7910/DVN/LQPHOB  


######## Please make sure to set the working directory:

 setwd("Final_JPR")


---

## Structures of the Replication files  

### 1. Code  
This directory contains R scripts to replicate all figures and tables from the main text and online appendix.  

#### (1) Main Results  
- **`1_figure_1.R`** – Replicates Figure 1  
- **`2_Table1_Figures_2-3.R`** – Replicates Table 1 and Figures 2-3  
- **`3_figure_4.R`** – Replicates Figure 4  

#### (2) Appendix Code  
- **`Appendix_Figure_A1.R`** – Replicates Appendix Figure A1  
- **`Appendix_Figure_A2.R`** – Replicates Appendix Figure A2  
- **`Appendix_Figure_A3-A6.R`** – Replicates Appendix Figures A3 to A6  
- **`Appendix_Figure_A7_Table_A18.R`** – Replicates Appendix Figure A7 and Table A18  
- **`Appendix_Table_A1.R`** – Replicates Appendix Table A1  
- **`Appendix_Table_A2-A7.R`** – Replicates Appendix Tables A2 to A7  
- **`Appendix_Table_A8-A17.R`** – Replicates Appendix Tables A8 to A17  

#### (3) Utility Scripts  
These scripts provide functions for calculating marginal effects and generating visualizations. They are loaded automatically into R.  
- **`coefplot.R`**  
- **`marginal_effects.R`**  
- **`setup.R`**  

---

### 2. Data  
The datasets used in this research are stored in this directory.  
- **`paperdata.RData`** – Main dataset for all models (excluding Table A18)  
- **`data-tek.csv`** – Raw data from EPR Growup used to generate Figure 1  
- **`paperdata_nokin.RData`** – Dataset for Table A18 analysis (Appendix)  

---

### 3. Figures  
Output figures generated by R scripts are saved here.  
- **`appendix_figures`** – Sub-folder for appendix figures  

---

### 4. Tables  
Tables generated by R scripts are saved in this directory.  
- **`appendix_tables`** – Sub-folder for appendix tables  

---

## Environment Information  
This project was developed and tested using the following environment:  
- **R Version:** 4.2.1 (2022-06-23)  
- **Platform:** x86_64-apple-darwin17.0 (64-bit)  
- **Operating System:** macOS 14.3  

### Key R Packages  
attached base packages:[1] grid      tcltk     stats     graphics  grDevices utils     datasets  methods   base     other attached packages: [1] randomForest_4.7-1.1  showtext_0.9-5        showtextdb_3.0        sysfonts_0.8.8        ggtext_0.1.1          [6] ggrepel_0.9.1         ggridges_0.5.4        viridis_0.6.2         viridisLite_0.4.2     gridExtra_2.3        [11] lmtest_0.9-40         multiwayvcov_1.2.3    postregplots_0.1.0    devtools_2.4.4        usethis_2.1.6        [16] lubridate_1.9.3       forcats_1.0.0         stringr_1.5.1         purrr_1.0.2           tibble_3.2.1         [21] tidyverse_2.0.0       sbgcop_0.980          Amelia_1.8.1          Rcpp_1.0.11           stargazer_5.2.3      [26] pscl_1.5.5            sqldf_0.4-11          RSQLite_2.2.18        gsubfn_0.7            proto_1.0.0          [31] rgdal_1.5-30          mapdata_2.3.1         dplyr_1.1.4           car_3.1-0             carData_3.0-5        [36] foreign_0.8-82        ggplot2_3.5.0         reshape2_1.4.4        texreg_1.38.6         haven_2.5.3          [41] zoo_1.8-10            pwt9_9.1-0            tidyr_1.3.0           gpclib_1.5-6          raster_3.5-21        [46] rgeos_0.5-9           arm_1.13-1            lme4_1.1-30           Matrix_1.4-1          MASS_7.3-57          [51] countrycode_1.4.0     spatstat_2.3-4        spatstat.linnet_2.3-2 spatstat.core_2.4-4   rpart_4.1.16         [56] nlme_3.1-157          spatstat.random_2.2-0 spatstat.geom_2.4-0   spatstat.data_2.2-0   readstata13_0.10.0   [61] cshapes_2.0           cem_1.1.31            lattice_0.20-45       MatchIt_4.4.0         gstat_2.1-0          [66] spdep_1.2-5           spData_2.0.1          sf_1.0-8              readr_2.1.4           maptools_1.1-4       [71] rworldmap_1.3-6       sp_2.1-1              maps_3.4.0 

---

If you encounter any issues or need further clarification, feel free to contact the authors.
